package com.maxatime.service.impl;

import com.maxatime.dao.ClassroomMapper;
import com.maxatime.exception.PhoenixException;
import com.maxatime.pojo.Classroom;
import com.maxatime.pojo.ClassroomVo;
import com.maxatime.service.ClassroomService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author Mr.Zhao
 * @title: ClassroomServiceImpl
 * @projectName phoenix
 * @description: TODO
 * @date 2021/7/26 10:38
 */
@Service
public class ClassroomServiceImpl implements ClassroomService {
       Logger log= LogManager.getLogger();


    @Autowired
    private ClassroomMapper classroomMapper;
    @Override
    public List<Classroom> classroomFind(ClassroomVo vo) {
        return classroomMapper.classroomFind(vo);
    }

    @Override
    public Integer classDelete(int pkId) {
        return classroomMapper.classDelete(pkId);
    }

    @Override
    public Integer updateClass(Classroom clas) throws PhoenixException {
        try {
            return classroomMapper.updateByPrimaryKeySelective(clas);
        }catch (Exception e){
            log.error("classroomMapper.updateByPrimaryKeySelective:::"+clas);
            log.error("classroomMapper.updateByPrimaryKeySelective:::"+e.getMessage());
            throw new PhoenixException("9999","修改失败");

        }


    }

    @Override
    public Integer insertClass(Classroom clas) throws PhoenixException {
        try {
            return classroomMapper.insertSelective(clas);
        }catch (Exception e){
            log.error("classroomMapper.updateByPrimaryKeySelective:::"+clas);
            log.error("classroomMapper.updateByPrimaryKeySelective:::"+e.getMessage());
            throw new PhoenixException("9999","添加失败");

        }


    }

    @Override
    public Integer deleteListClass(List<Integer> list) {
        return classroomMapper.deleteListClass(list);
    }

    @Override
    public List<Classroom> findBuildingNo(String area) {
        return classroomMapper.findBuildingNo(area);
    }

    @Override
    public List<Classroom> findBuildingFloor(String area, String bNo) {
        return classroomMapper.findBuildingFloor(area,bNo);
    }

    @Override
    public List<Classroom> findArea() {
        return classroomMapper.findArea();
    }
}
